#ifndef IOOPS_H__
#define IOOPS_H__

#include "defines.h"
#include "xmppLogger.h"
#include <string>

class IoOps {
  public:
    IoOps(xmppLogger *logger=NULL);
    IoOps(const IoOps&);
    xret connect(const std::string &host, const int port);
    xret watch(const ioevent watch_ev, ioevent &trigg_ev, short timeout );
#if 0
/*iksemel provides it*/
    xret read(char *buf, const ssize_t len, ssize_t &read_len);
    xret write(char *buf, const ssize_t len, ssize_t &write_len);
#endif
    inline xret getFD(int *fd) { *fd = this->fd; return xp_OK; }
    inline xret getAlertFD(int *fd) { *fd = this->alert_fds[1]; return xp_OK; }
    inline xret getAlertReadFD(int *fd) { *fd = this->alert_fds[0]; return xp_OK; }
    xret getStatus();
    xret close(void);
  protected:
    xret nonblocking(int &socket, unsigned short enable);
    xret sock_pton(const char *host, struct in_addr *inp);
    xret gethostinfo(const char *host,struct hostent **hp);
  private:
    std::string host;
    int port;
    int fd;
    int alert_fds[2];
    iostat status;
    xmppLogger *log;
};

#endif
/*
vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=2:encoding=utf-8:textwidth=80
*/
